package com.zxc.dbconnectionpool;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author zhou xiaochen
 * 
 */
public class DBConnectionPool {
	private List<Connection> pool;
	private Connection conn;
	private int poolSize = 1;
	private static DBConnectionPool instance;

	/**
	 * get an instance of DBConnectionPool
	 * 
	 * @return an instance of DBConnectionPool
	 */
	public DBConnectionPool getInstance() {//this is not a singleton
		if (instance == null) {
			instance = new DBConnectionPool();
		}
		return instance;
	}

	/**
	 * make the construct private, DBConnectionPool singleton. use getInstance
	 * method to get the DBConnectionPool instance.
	 */
	private DBConnectionPool() {
		pool = new ArrayList<Connection>();
		this.createConnection();
	}
   //edit

	/**
	 * create the database connection and put them into the pool.
	 */
	private void createConnection() {
		int temp = ResourceManager.getPoolSize();
		if (temp > 0) {
			poolSize = temp;
		}
	}
}






